﻿import flash.display.DisplayObject;
import flash.display.DisplayObjectContainer;
import flash.display.Sprite;
import mclight.Component;
import mclight.Layoutable;

class _Container extends Component
{
	public function new()
	{
		super();
	}
	
	var _content:Sprite;
	
	var _childs:Array<Layoutable>;
	
	public function add(?child:DisplayObject, ?component:Component, index:Int = -1)
	{
		if (index == -1)
		{
			index = _content.numChildren;
		}
		if (child != null)
		{
			_content.addChildAt(child, index);
		}
		if (component != null)
		{
			_content.addChildAt(component._sprite, index);
		}
		invalidate();
	}
	
	public function contains(?child:DisplayObject, ?component:Component)
	{
		if (child != null && component != null)
		{
			throw 'Too many arguments';
		}
		return child != null && _content.contains(child) || component != null && _content.contains(component._sprite);
	}
}